package com.zhongen.wflow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhongen.admin.api.entity.SysDept;
import com.zhongen.admin.api.entity.SysUserDept;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author : willian fu
 * @date : 2022/6/27
 */
public interface WflowUserDepartmentsMapper extends BaseMapper<SysUserDept> {

	/**
	 * 查询指定用户所在的部门，一个用户可能同时在多个部门下
	 * @param userId 用户ID
	 * @return 用户所在的部门列表
	 */
	@Select("SELECT wd.dept_id, wd.name FROM sys_user_dept wud, sys_dept wd WHERE wud.dept_id = wd.dept_id AND wud.user_id = #{userId}")
	List<SysDept> getUserDepts(@Param("userId") String userId);

}
